
import requests
import json

# 机器人发送信息的API
url = 'https://oapi.dingtalk.com/robot/send?access_token=5c55ff3b8f338041a4b04e82c13c2fea3ff3edf3844fde2d99261607aae54a57'

# 指定请求头
headers = {
    'Content-Type': 'application/json; charset=UTF-8'
}

# 与机器人API 交互的数据
# data  = {
#     'msgtype': 'text',  # 信息类型： 文字
#     'text': {
#         'content': '好好学习，天天向上，我是巴拉巴拉机器人。@13999998888'
#     },
#     'at': {
#         'atMobiles':[
#             '134xxxx0215',
#             '13999998888'
#         ],
#         'isAtAll': False  # 不 @所有人
#     }
# }

data = {
    "msgtype": "markdown",
    "markdown": {
        "title": "春节放假通知",
        "text": """## 放假通知
![](http://aid.codeboy.com:8008/static/python/_images/202102.jpeg)
好好学习天天向上 [TMOOC](http://tmooc.cn)
"""
    },
    "at": {
        "atMobiles": [
            "13488820215"
        ],
        "isAtAll": False
    }
}

r = requests.post(url, headers=headers, data=json.dumps(data))

import pprint
pprint.pprint(r.json())